package com.chuangxin.data.core;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;

/**
 * Created by Dawnwords on 2015/2/1.
 */
public class Logger {
    private static PrintWriter succeed, fail;

    static {
        try {
            succeed = new PrintWriter(new FileOutputStream("success", true));
            fail = new PrintWriter(new FileOutputStream("error", true));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    public static void succeed(String msg) {
        System.out.println("[Success]" + msg);
        succeed.println("[Success]" + msg);
        succeed.flush();
    }

    public static void fail(String reason, String msg) {
        System.err.printf("[%s Fail]%s\n", reason, msg);
        fail.printf("[%s Fail]%s\n", reason, msg);
        fail.flush();
    }
}
